package com.controller.chart;

import com.model.pojo.annotation.CheckToken;
import com.model.bo.GroupUpdateId;
import com.model.pojo.RepEntity;
import com.model.pojo.TestPage;
import com.model.vo.configVo.ChangeOrderInfo;
import com.model.vo.configVo.ChartConfigInfo;
import com.model.vo.configVo.GroupInfo;
import com.server.chart.ChartsConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ChartsConfigController {
    @Autowired
    ChartsConfigService chartsConfigService;

   /*
   添加
    */
    @CheckToken
    @RequestMapping("/inputCharts")
    public RepEntity inputCharts(@RequestHeader String token,@RequestBody ChartConfigInfo body){
        return chartsConfigService.setChartsConfig(body, token);
    }

    /*
   更新
    */
    @CheckToken
    @RequestMapping("/updateCharts")
    public RepEntity updateCharts(@RequestHeader String token,@RequestBody ChartConfigInfo body){
        return chartsConfigService.updateChartsConfig(body, token);
    }

    /*
    移交图表
     */
    @CheckToken
    @RequestMapping("/changeChartOrder")
    public RepEntity changeChartOrder(@RequestHeader String token, @RequestBody ChangeOrderInfo body){
        return chartsConfigService.changeChartOrder(body, token);
    }

    /*
    更新图表的分组
     */
    @CheckToken
    @RequestMapping("/updateChartConfigGroup")
    public RepEntity updateConfigGroup(@RequestHeader String token, @RequestBody GroupUpdateId body){
        return chartsConfigService.updateConfigGroup(body);
    }

    /*
    删除
     */
    @CheckToken
    @RequestMapping("/delChartsConfig")
    public RepEntity delChartsConfig(@RequestHeader String token,@RequestBody List<Integer> body){
        return chartsConfigService.delChartsConfig(body);
    }

    /*
    查询图表列表
     */
    @CheckToken
    @RequestMapping("/getListCharts")
    public RepEntity getListCharts(@RequestHeader String token, @RequestBody TestPage body){
        return chartsConfigService.getListCharts(token, body);
    }

    /*
    查询单个图表
     */
    @CheckToken
    @RequestMapping("/getChartsConfig")
    public RepEntity getChartsConfig(@RequestHeader String token,@RequestBody int body){
        return chartsConfigService.getOneCharts(body);
    }

    /*
    添加图表分组
     */
    @CheckToken
    @RequestMapping("/setChartsGroup")
    public RepEntity setChartsGroup(@RequestHeader String token, @RequestBody GroupInfo body){
        return chartsConfigService.setDataConnectorGroup(body);
    }

    /*
    更新图表分组
     */
    @CheckToken
    @RequestMapping("/updataChartsGroup")
    public RepEntity updataChartsGroup(@RequestHeader String token,@RequestBody GroupInfo body){
        return chartsConfigService.updataDataConnectorGroup(body);
    }

    /*
    批量更新图表
     */
    @CheckToken
    @RequestMapping("/updataListGroup")
    public RepEntity updataListGroup(@RequestHeader String token,@RequestBody List<GroupInfo> body){
        return chartsConfigService.updataListGroup(body);
    }

    /*
    删除图表分组
     */
    @CheckToken
    @RequestMapping("/delChartsGroup")
    public RepEntity delChartsGroup(@RequestHeader String token,@RequestBody List<Integer> body){
        return chartsConfigService.delDataConnectorGroup(body);
    }

    /*
    查询图表分组
     */
    @CheckToken
    @RequestMapping("/getChartsGroup")
    public RepEntity getChartsGroup(@RequestHeader String token){
        return chartsConfigService.getConnectorGroup();
    }

}
